﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Test10();



        }
        static void Test1()
        {
            string[] arr = { "1", " 2", " 3", "4", " 5" };

            for (int i = 0; i < arr.Length; i++)
            {
                if (i % 2 == 0)
                {
                    Console.WriteLine(arr[i]);
                }
            }
            Console.ReadKey();
        }
        static void Test2()
        {
            Console.WriteLine("请输入一个字符串");
            string a = Console.ReadLine();
            int sum = 0;
            int sum1 = 0;
            int sum2 = 0;
            foreach (var c in a)
            {
                if (char.IsDigit(c))
                {
                    sum++;
                }
                if (char.IsLetter(c))
                {
                    sum1++;
                }
                if (char.IsWhiteSpace(c))
                {
                    sum2++;
                }

                Console.WriteLine(c);
            }

            Console.WriteLine("英文字母有{0},数字有{1},空格{2}", sum1, sum, sum2);
            Console.ReadKey();
        }
        static void Test3()
        {
            double[] acc = new double[5];
            double sum = 0;
            double chu = 0;
            for (int i = 0; i < acc.Length; i++)
            {
                Console.WriteLine("请输入数据");
                double s = double.Parse(Console.ReadLine());
                acc[i] = s;

            }
            foreach (double qwe in acc)
            {
                sum += qwe;
                chu = sum / 5;

            }

            Console.WriteLine("和是{0}平均是{1}", sum, chu);
            Console.ReadKey();
        }
        static void Test4()
        {
            int[] a = { 10, 58, 36, 78, 42 };
            int temp = 0;
            for (int i = 0; i < a.Length - 1; i++)
            {
                for (int j = 0; j < a.Length - i - 1; j++)
                {
                    if (a[j] < a[j + 1])
                    {
                        temp = a[j];
                        a[j] = a[j + 1];
                        a[j + 1] = temp;

                    }
                }
            }
            Console.WriteLine("结果是");
            foreach (int item in a)
            {
                Console.Write(item + " ");
            }
            Console.ReadKey();

        }
        static void Test5()
        {
            int[] ba = { 10, 20, 45, 87, 92 };
            Console.WriteLine("请输入一个数");
            int a = int.Parse(Console.ReadLine());
            int index = -1;
            for (int i = 0; i < ba.Length; i++)
            {
                if (a == ba[i])
                {
                    index = i;

                }

            }
            if (index != -1)
            {
                Console.WriteLine("{0}在数组中出现的位置是{1}", a, index);

            }
            else
            {
                Console.WriteLine("找不到");
            }

            Console.ReadKey();
        }
        static void Test6()
        {
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j <= i; j++)
                {
                    Console.Write(i + "*" + j + "=" + i * j + "\t");

                }
                Console.WriteLine();

            }
            Console.ReadKey();
        }
        static void Test7()
        {
            Console.WriteLine("用户输入");
            int s = int.Parse(Console.ReadLine());
            for (int i = 0; i < s; i++)
            {

                for (int j = 0; j < s; j++)
                {
                    Console.Write("*");

                }
                Console.WriteLine();

            }
            Console.ReadKey();
        }
        static void Test8()
        {
            Console.WriteLine("用户输入");
            int s = int.Parse(Console.ReadLine());
            for (int i = 0; i < s; i++)
            {
                for (int j = 0; j < s; j++)
                {
                    if (0 == j || j == s - 1 || i == 0 || i == s - 1)
                    {
                        Console.Write("*" + " ");
                    }
                    else
                    {
                        Console.Write(" " + " ");
                    }

                }
                Console.WriteLine();

            }
            Console.ReadKey();


        }
        static void Test9()
        {
            Console.WriteLine("输入菱形的行数：");
            string str = Console.ReadLine();
            int n = int.Parse(str);
            for (int i = 1; i <= n; i++)
            {
                for (int j = n - 1; j >= i ; j--)
                {
                    Console.Write(" ");
                }
                for (int p = 1; p <= i*2-1; p++)
                {

                Console.Write("*");
                }
                Console.WriteLine();
            }
            for (int i = n - 1; i >= 1; i--)
            {
                for (int j = i - 1; j < n - 1; j++)
                {
                    Console.Write(" ");
                }
                for (int p = 1; p <= i * 2 - 1; p++)
                {
                    Console.Write("*");
                }
                Console.WriteLine();
            }
        }
        static void Test10() {
            int[] arr = { 89, 67, 42, 11 };

            Console.WriteLine("请输入一个插进数组的数");
            int index = int.Parse(Console.ReadLine());

            int[] arr1 = new int[arr.Length + 1];

            for (int i = 0; i < arr.Length; i++)
            {
                arr1[i] = arr[i];
            }
            arr1[arr1.Length - 1] = index;

            for (int i = 0; i < arr1.Length - 1; i++)
            {
                for (int j = 0; j < arr1.Length - i - 1; j++)
                {
                    if (arr1[j] < arr1[j + 1])
                    {
                        int temp = arr1[j];
                        arr1[j] = arr1[j + 1];
                        arr1[j + 1] = temp;
                    }
                }
            }

            for (int i = 0; i < arr1.Length; i++)
            {
                Console.Write(arr1[i] + " ");
            }
        }
    }
}

